<?php

namespace app\frontend\controller;

use app\frontend\library\DataController;
use app\common\model\PaymentSetting as paymentSettingModel;

class PaymentSetting extends DataController
{
    protected $mdl = PaymentSettingModel::class;

    public function getOne()
    {
        $filter = [
            'status' => $this->mdl::ENABLED_STATUS,
            'is_deleted' => $this->mdl::NO_DELETED,
        ];
        $modelRecord = $this->mdl::field(['id', 'quota', 'pay_url', 'priority'])->where($filter)->order(['priority' => 'desc'])->find();

        if(!empty($modelRecord->quota)) {
            $modelRecord->quota = json_decode($modelRecord->quota, true);
        }

        return $this->jsonSuccess('success', $modelRecord);
    }
}